<html>
<head><meta charset="utf-8"><title>Setting RUSTFLAGS from the API · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html">Setting RUSTFLAGS from the API</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="231437150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/231437150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbato <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#231437150">(Mar 23 2021 at 08:39)</a>:</h4>
<p>Is there a simple way to pass additional rustflags from the API? I couldn't see a way so far.</p>



<a name="234483585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/234483585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbato <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#234483585">(Apr 14 2021 at 11:41)</a>:</h4>
<p>I take it as a no :P</p>



<a name="234487222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/234487222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#234487222">(Apr 14 2021 at 12:13)</a>:</h4>
<p>The easiest way to pass rustflags is through the <code>RUSTFLAGS</code> env var.  I don't know of another way. <code>cargo rustc -- &lt;rustflags-go-here&gt;</code> may be what you're looking for? But I don't really know if I understand your question correctly.</p>



<a name="234669794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/234669794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbato <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#234669794">(Apr 15 2021 at 12:58)</a>:</h4>
<p>I'm using cargo as a crate. RUSTFLAGS are taken as env only from what I could see, but cargo is fairly big so I might had overlooked something.</p>



<a name="234669901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/234669901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbato <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#234669901">(Apr 15 2021 at 12:59)</a>:</h4>
<p>what <code>cargo rustc</code> takes is a field in a struct, you can set, but if you want to set flags for the dependencies as well you have no way beside using the env</p>



<a name="234705332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/234705332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#234705332">(Apr 15 2021 at 16:07)</a>:</h4>
<p>I'm not a cargo expert, but in Clippy we just use the <code>RUSTFLAGS</code> env var to pass flags to cargo.</p>



<a name="234706376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/234706376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#234706376">(Apr 15 2021 at 16:13)</a>:</h4>
<p>Hmm...? Doesn't Clippy use that hacky <code>CLIPPY_ARGS</code>?</p>
<div class="codehilite" data-code-language="Bash Session"><pre><span></span><code><span class="gp">[rust-clippy]$ </span>fgrep RUSTFLAGS -r .
<span class="gp">[rust-clippy]$ </span><span class="nb">echo</span> <span class="nv">$?</span>
<span class="go">1</span>
</code></pre></div>



<a name="234706948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/234706948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#234706948">(Apr 15 2021 at 16:16)</a>:</h4>
<p>Doesn't it use both? I really don't know (and don't want to know) what goes on in our driver code anymore :D Maybe it was just what Eduardo attempted to do before to fix _$something_ and it's now burned into my mind that Clippy uses the <code>RUSTFLAGS</code> env var.</p>
<p>In this case, I think Clippy uses <code>CLIPPY_ARGS</code> (which is clippy internal) to track what should be passed to <code>cargo rustc -- ...</code></p>



<a name="234707057"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/234707057" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#234707057">(Apr 15 2021 at 16:17)</a>:</h4>
<blockquote>
<p>and don't want to know</p>
</blockquote>
<p>Unless the unfortunate day arrives where I have to deal with this again for some reason, of course.</p>



<a name="235160930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Setting%20RUSTFLAGS%20from%20the%20API/near/235160930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Luca Barbato <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Setting.20RUSTFLAGS.20from.20the.20API.html#235160930">(Apr 19 2021 at 10:52)</a>:</h4>
<p>I guess I'll bake a patch to make the API vs env experience a little more uniform.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>